//
//  AccountLoginModel.m
//  LearnObjectiveC
//
//  Created by 吴可高 on 16/3/28.
//  Copyright © 2016年 吴可高. All rights reserved.
//

#import "AccountLoginModel.h"
#import <objc/runtime.h>

@implementation AccountLoginModel

-(void)objectDidFinishConvertingToKeyValues
{
    unsigned int count = 0;
    Method *mothds = class_copyMethodList([self class], &count);
    SEL selector = method_getName(mothds[0]);

}


- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super init];
    if (self) {
        unsigned int count = 0;
        objc_property_t * properties = class_copyPropertyList([self class], &count);
        for (int i = 0; i < count; i++) {
            const char * propertyName = property_getName(properties[i]);
            NSString * key = [NSString stringWithCString:propertyName encoding:NSUTF8StringEncoding];
            id value =  [coder decodeObjectForKey:key];
            [self setValue:value forKey:key];
        }
        free(properties);
    }
    return self;
}

- (void)encodeWithCoder:(NSCoder *)coder
{
    unsigned int count = 0;
    objc_property_t * properties = class_copyPropertyList([self class], &count);
    for (int i = 0; i < count; i++) {
        const char * propertyName = property_getName(properties[i]);
        NSString * key = [NSString stringWithCString:propertyName encoding:NSUTF8StringEncoding];
        id value = [self valueForKey:key];
        [coder encodeObject:value forKey:key];
    }
    free(properties);
}


@end
